package com.hqd.jjvm.classformat.constantpool;

import com.hqd.jjvm.classformat.ClassFile;
import com.hqd.jjvm.util.HexStrTransformUtil;
import lombok.Getter;

@Getter
public class ConstantNameAndTypeInfo extends ConstantPool {
	private Integer nameIndex;
	private Integer descriptorIndex;

	public ConstantNameAndTypeInfo(ConstantInfoType tag, ClassFile classFile) {
		super(tag, classFile);
		this.nameIndex = HexStrTransformUtil.parseHexToInt(classFile.readU2());
		checkPoolIndex(nameIndex);
		this.descriptorIndex = HexStrTransformUtil.parseHexToInt(classFile.readU2());
		checkPoolIndex(descriptorIndex);
	}

	@Override
	public Object getVal() {
		return this;
	}
}
